/* 

	Auto Language Selector v1.1 - (C) 2003-2004, Jack (tR) http://www.jtr.de/scripting/javascript
	This script is published under GPL Version 2+ (see http://www.fsf.org)
	
	The script looks up for browser language code (e.g. [de]) and reloads the current web 
	page adding the corresponding parameter language=... (e.g. ?language=german) to the url!
	
	Credits go to Zvonko & MReuring !

*/

if( this.location.href.indexOf("language=")<0 )
{
	if (navigator.language) 
		{ var language_str = navigator.language;}
	else 
		{ var language_str = navigator.browserLanguage;}

	switch( language_str.substr(0,2) ) 
	{
		case "af" : lang_sel = "afrikaans"; break;
		case "ar" : lang_sel = "arabic"; break;
		case "be" : lang_sel = "russian"; break;
		case "bg" : lang_sel = "bulgarian"; break; 
		case "ca" : lang_sel = "catalan"; break;
		case "cs" : lang_sel = "czech"; break;
		case "da" : lang_sel = "danish"; break;
		case "de" : lang_sel = "german"; break;
		case "el" : lang_sel = "greece"; break;
		case "en" : lang_sel = "english"; break;
		case "es" : lang_sel = "spanish"; break;
		case "et" : lang_sel = "estonian"; break;
		case "eu" : lang_sel = "basque"; break;	
		case "fa" : lang_sel = "farsi"; break;	
		case "fi" : lang_sel = "finnish"; break;
		case "fo" : lang_sel = "faeroese"; break;
		case "fr" : lang_sel = "french"; break;
		case "gd" : lang_sel = "gaelic"; break;
		case "he" : lang_sel = "hebrew"; break;
		case "hi" : lang_sel = "hindi"; break;
		case "hr" : lang_sel = "croatian"; break;
		case "hu" : lang_sel = "hungarian"; break;
		case "in" : lang_sel = "indonesian"; break;
		case "is" : lang_sel = "icelandic"; break;
		case "it" : lang_sel = "italian"; break;
		case "ja" : lang_sel = "japanese"; break;
		case "ko" : lang_sel = "korean"; break;
		case "lt" : lang_sel = "lithuanian"; break;
		case "lv" : lang_sel = "latvian"; break;
		case "mk" : lang_sel = "macedonian"; break;
		case "ms" : lang_sel = "malaysian"; break;	
		case "mt" : lang_sel = "maltese"; break;	
		case "nl" : lang_sel = "dutch"; break;	
		case "pl" : lang_sel = "polish"; break;	
		case "pt" : lang_sel = "portuguese"; break;	
		case "rm" : lang_sel = "romanic"; break;	
		case "ro" : lang_sel = "romanian"; break;	
		case "ru" : lang_sel = "russian"; break;	
		case "sb" : lang_sel = "sorbian"; break;	
		case "sk" : lang_sel = "slovak"; break;	
		case "sq" : lang_sel = "albanian"; break;	
		case "sr" : lang_sel = "serbian"; break;	
		case "sv" : lang_sel = "swedish"; break;	
		case "sl" : lang_sel = "slovenian"; break;
		case "sx" : lang_sel = "sutu"; break;
		case "sz" : lang_sel = "sami"; break;	
		case "th" : lang_sel = "thai"; break;		
		case "tn" : lang_sel = "tswana"; break;		
		case "tr" : lang_sel = "turkish"; break;		
		case "ts" : lang_sel = "tsonga"; break;
		case "uk" : lang_sel = "ukrainian"; break;
		case "ur" : lang_sel = "urdu"; break;
		case "ve" : lang_sel = "venda"; break;	
		case "vi" : lang_sel = "vietnamese"; break;	
		case "xh" : lang_sel = "xhosa"; break;			
		case "zh" : lang_sel = "chinese"; break;			
		case "zu" : lang_sel = "zulu"; break;			
		default   : lang_sel = "english"; break;	
	}


	if (this.location.search) 
	{
	    this.location.replace(this.location.href + "&language=" + lang_sel);
	} else 
		{
		    this.location.replace(this.location.href + "?language=" + lang_sel);
		}
}
